package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Awardauthor;
import com.hbnu.system.service.IAwardauthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/awardauthor")
@Api(tags = "成果的作者管理")
public class AwardauthorController {

    @Autowired
    IAwardauthorService iAwardauthorService;
    @ApiOperation("新增成果作者")
    @PostMapping("/addauthor")
    public Rest<String> addAuthor(@RequestBody Awardauthor awardauthor){
        boolean ba = iAwardauthorService.addAwardAuthor(awardauthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除作者信息")
    @GetMapping("/deleteauthor")
    public Rest<String> delete(String id){
        boolean ba1 = iAwardauthorService.deleteAwardAuthor(id);
        return ba1?Rest.success():Rest.failed();
    }
    @ApiOperation("修改作者信息")
    @GetMapping("/updateauthor")
    public Rest<String> updateAuthor(Awardauthor awardauthor){
        boolean ba2=iAwardauthorService.updateAwardAuthor(awardauthor);
        return ba2?Rest.success():Rest.failed();
    }
    @ApiOperation("搜索作者信息")
    @GetMapping("/selectauthor")
    public Rest<List<Awardauthor>> selectAuthor( String id){
        List<Awardauthor> pa=iAwardauthorService.listAuthor(id);
        return Rest.success(pa,pa.size());
    }

}

